﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace XTYAPI.PLC
{
    /// <summary>
    /// 一键启停，可以一直死循环扫描，沿脉冲触发
    /// </summary>
    public class ALTP
    {  
        /// <summary>
        /// 获取输出结果
        /// </summary>
        public bool OutPut { get; private set; }
        /// <summary>
        /// 上升沿对象
        /// </summary>
        R_TRIG r = new R_TRIG();
        bool input;//字段缓存
        /// <summary>
        /// 触发器 每个扫描周期都可以赋值
        /// </summary>
        public bool InPut { get { return input; }set { input = value; CalALTP(input); } }
        /// <summary>
        /// 计算器
        /// </summary>
        /// <param name="state"></param>
        void CalALTP(bool state) 
        {
            r.CLK = state;
            if (r.Q)
            {
                OutPut = !OutPut;
            }
        }
    }
}
